<template>
	<div class="customer" style="padding: 40px 20px 40px 0">
		<el-row :span="24" style="margin:0;">
			<el-row style="margin-bottom: 20px;">
				<el-col :span="24">
					<span style="font-size: 18px;margin-left: 10px;">交易管理>全部订单</span>
				</el-col>
			</el-row>
			<div style="background-color: #f4f5f6;">
				<div class="row" style="background-color: #FFFFFF;padding: 15px 15px 15px 5px; width: 85%;">
					
					<div class="select" style="margin-top: 0;">
						<div>商品名称</div>
						<div>
							<el-input size="small" class="input2" style="margin-left: 10px;" v-model="formInline.goodName"></el-input>
						</div>
					</div>
					<div class="select" style="margin-top: 0;">
						<div>买家用户名</div>
						<div>
							<el-input size="small" class="input2" style="margin-left: 10px;" v-model="formInline.userName"></el-input>
						</div>
				
					</div>
					
					<div class="select" style="margin-top: 0;">
						<div>订单号</div>
						<div>
							<el-input size="small" class="input2" style="margin-left: 10px;" v-model="formInline.name"></el-input>
						</div>
					</div>
				</div>
				<div class="row" style="background-color: #FFFFFF;padding: 15px 15px 15px 5px; width: 85%;">
					
					<div class="select" style="margin-top: 0;">
						<div>时间筛选</div>
						<div>
							<el-date-picker   type="date" placeholder="开始时间" v-model="startTime" style="width:180px;margin-left: 10px;"></el-date-picker>
							到
							<el-date-picker   type="date" placeholder="结束时间" v-model="endTime" style="width:180px;margin-left: 10px;"></el-date-picker>
						</div>
					</div>
					<div class="select" style="margin-top: 0;">
						<el-button type="primary" @click="findDataInfo()">查询</el-button>
						<el-button type="infor" size="big" plain @click="clear()">重置</el-button>
					</div>
				</div>
			<div v-if="appData == '1'" class="row" style="background-color: #FFFFFF;padding: 15px 15px 15px 5px; width: 85%;">
				<div class="select" style="margin-top: 0;">
					<div>物流公司</div>
					<div>
						<el-select size="small" class="input2" style="margin-left: 10px;" v-model="orderLogicCompany">
							<el-option :label="item.logisticsName" :value="item.logisticsName" v-for="item in company_list"></el-option>
						</el-select>
					</div>
				</div>
				
				<!-- 	<div class="select" style="margin-top: 0;">
						<div>价格</div>
						<div>
							<el-input size="small" style="margin-left: 10px;width: 100px;" v-model="formInline.goodId"></el-input>
							——
							<el-input size="small" style="margin-left: 10px;width: 100px;" v-model="formInline.goodId"></el-input>
						</div>
					</div> -->
				<div class="select" style="margin-top: 0;">
					<input type="file" name="excel" style="display: none;" id="excel" @change="updata($event)">
					<el-button type="infor" plain @click="toLead"  style="margin-left: 8px;">导入</el-button>
			
				</div>
				<div class="select" style="margin-top: 0;">
					<el-button type="infor" plain @click="deriveList"  style="margin-left: 8px;">导出待发货列表</el-button>
							
				</div>
			</div>
						
			</div>
			<!-- 		<div style="background-color: #f4f5f6;">
				<div class="row" style="background-color: #f4f5f6;padding: 15px 15px 0 15px; width: 90%;">
					<div class="select" style="margin-top: 0;">
						<div>买家昵称</div>
						<div>
							<el-input size="small" class="input1" style="margin-left: 10px;" v-model="formInline.userName"></el-input>
						</div>
				
					</div>
					<div class="select" style="margin-top: 0;">
						<div>订单号</div>
						<div>
							<el-input size="small" class="input1" style="margin-left: 10px;" v-model="formInline.name"></el-input>
						</div>
					</div>
					<div class="select" style="margin-top: 0;">
						<div>价格</div>
						<div>
							<el-input size="small" style="margin-left: 10px;width: 100px;" v-model="formInline.goodId"></el-input>
							——
							<el-input size="small" style="margin-left: 10px;width: 100px;" v-model="formInline.goodId"></el-input>
						</div>
					</div>
				</div>
				<div class="row" style="margin-left: 25px;padding-bottom: 15px;">
					<el-button  type="primary" size="big" plain @click="fetchData(1)">查询</el-button>
					<el-button  type="primary" size="big" plain @click="clear()">重置</el-button>
				</div>
			</div> -->
			<!-- 		<div style="background-color: #FFFFFF;padding: 15px 15px 15px 5px; width: 85%;margin-top: 40px;">
				<el-form :inline="true" :model="formInline" class="demo-form-inline" label-width="100px" style="">
					<el-form-item label="支付方式">
						<el-select v-model="formInline.orderPayType" style="width: 150px;">
							<el-option label="全部" value=""></el-option>
							<el-option :label="item.text" :value="item.value" v-for="item in payWay"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="下单时间">
						<el-date-picker type="date" placeholder="开始时间" v-model="startTime" style="width:180px;"></el-date-picker>
						到
						<el-date-picker type="date" placeholder="结束时间" v-model="endTime" style="width:180px;"></el-date-picker>
					</el-form-item>
					<el-form-item label="催单" label-width="50px">
						<el-select v-model="formInline.orderIsRemind" style="width: 150px;">
							<el-option label="全部" value=""></el-option>
							<el-option label="被催单" value="1"></el-option>
						</el-select>
					</el-form-item>
					<br>
				
					<el-form-item label="买家用户名:">
						<el-input v-model="formInline.userName" style="width: 150px;"></el-input>
					</el-form-item>
					<el-form-item label="商品名称:">
						<el-input v-model="formInline.goodName" style="width: 150px;"></el-input>
					</el-form-item>
					<el-form-item label="订单号:">
						<el-select  v-model="formInline.type" style="width: 120px;" @change="changeType">
							<el-option label="订单号" value="orderId"></el-option>
							<el-option label="支付流水号" value="serialNo"></el-option>
						</el-select>
						<el-input v-model="formInline.name" style="width: 150px;" xlength="50"></el-input>
					</el-form-item>
				
					<el-button type="primary" @click="findDataInfo()">查询</el-button>
					<el-button type="infor" size="big" plain @click="clear()">重置</el-button>
				</el-form>
			</div> -->
			<el-tabs v-model="activeName" @tab-click="handleClick" style="width: 85%;">
				<el-tab-pane :label="'全部('+numberObj.totalNumber+')'" name="0"></el-tab-pane>
				<el-tab-pane :label="'待付款('+numberObj.notPayNumber+')'" name="1"></el-tab-pane>
				<el-tab-pane :label="'待发货('+numberObj.notReceiveNumber+')'" name="2"></el-tab-pane>
				<el-tab-pane :label="'待收货('+numberObj.receiveNumber+')'" name="4"></el-tab-pane>
				<el-tab-pane :label="'待评价('+numberObj.praiseNumber+')'" name="5"></el-tab-pane>
				<el-tab-pane :label="'已完成('+numberObj.okNumber+')'" name="6"></el-tab-pane>
				<el-tab-pane :label="'用户取消('+numberObj.userCancelNumber+')'" name="3"></el-tab-pane>
				<el-tab-pane :label="'系统取消('+numberObj.sysCancelNumber+')'" name="7"></el-tab-pane>
				<el-tab-pane :label="'退款中('+numberObj.returnNumber+')'" name="11"></el-tab-pane>
			</el-tabs>
		</el-row>
		<div v-if="pageInfo.dtos.length != '0'">
			<el-card v-for="item in pageInfo.dtos" style="margin-bottom: 20px;width: 85%;">
				<div slot="header" class="clearfix">
					<div style="display:inline-block;margin-top: 4px;">
						<div style="display:inline-block;margin-right: 10px;">订单号：{{ item.orderId }}</div>
						<div style="display:inline-block;margin-right: 10px;">支付流水号：{{ item.serialNo }}</div>
						<!-- <div style="margin: 0 20px;padding: 10px 0;">支付方式：{{ findType(item.orderPayType) }}</div> -->
						<div style="display:inline-block;">订单总价：{{ item.orderTotalAmount}}元</div>
					</div>

					<el-button style="float: right;margin-left: 20px;" type="primary" @click="$router.push('/mall/order_detail/'+item.orderId+'?type=1')"
					 v-if="item.shopOrderDetailDtos.length>1&&item.orderStat!=6">订单详情</el-button>
					<el-button style="float: right;" type="warning" v-if="item.orderIsRemind==1">被催单</el-button>
					<el-button style="float: right;margin-left: 20px" type="primary" v-if="item.orderStat==2&item.shopOrderDetailDtos.length>1 || item.orderStat==6&item.shopOrderDetailDtos.length>1"
					 @click="deliver(item.orderId,1)">一起发货</el-button>
					<el-button style="float: right;" type="primary" v-if="item.orderStat==6 || item.orderStat==7 || item.orderStat==8 || item.orderStat==10"
					 @click="$router.push('/mall/logistics_detail/'+item.orderId)">查看物流</el-button>
					<el-button style="float: right;margin-right: 15px;" type="success" v-if="item.refundsState==8" @click="checkReturn(item)">确认收到退货</el-button>
					<el-button style="float: right;" type="primary" v-if="item.orderStat==3||item.orderStat==11||item.orderStat==9"
					 @click="dialogFormVisible2=true;remark=item.orderCancelReason">取消原因</el-button>
				</div>
				<div class="el-table tr">
					<el-table tooltip-effect="dark" :data="item.shopOrderDetailDtos" v-loading="table_loading"
					 element-table_loading-text="加载中" stripe @sort-change='order' style="width: 100%">
						<el-table-column width="215" label="商品">
							<template scope="scope">
								<div style="display: inline-block;">
									<img class="banner" :src="scope.row.goodCover" style="width:55px;height: 55px;margin: 5px 0;">
								</div>
								<div style="display: inline-block;width: 120px;vertical-align: middle;padding: 10px;">{{scope.row.goodName}}</div>
							</template>
						</el-table-column>
						<el-table-column show-overflow-tooltip label="内部订单号" prop='detailId'>
						</el-table-column>
						<el-table-column label="单价/数量">
							<template scope="scope">
								<span>{{scope.row.goodPrice}}/{{ scope.row.buyNum }}</span>
							</template>
						</el-table-column>
						<el-table-column label="规格" prop='goodSpec'>
						</el-table-column>
						<el-table-column label="订单状态">
							<template scope="scope">
								<span>{{findState(scope.row.orderStat)}}</span>
							</template>
						</el-table-column>
						<el-table-column prop="userName" label="买家">
							<template scope="scope">
								<span>{{ item.userName }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="orderPlaceTime" label="下单时间" show-overflow-tooltip>
						</el-table-column>
						<!--  <el-table-column
			            label="订单总价"
			            prop='orderTotalAmount'>
			            <template scope="scope">
			                <span>{{item.orderTotalAmount}}</span>
			            </template>
			    </el-table-column> -->
						<el-table-column label="操作" width="120">
							<template scope="scope">
								<span class="pointer" v-if="item.shopOrderDetailDtos.length==1 || item.orderStat==6" @click="$router.push('/mall/order_detail/'+scope.row.detailId+'?type=2')">订单详情</span>
								<span class="pointer" v-if="scope.row.orderStat==6" @click="editGold(scope.row.detailId)">查看评价</span>
								<span class="pointer" v-if="scope.row.orderStat==4" @click="changeLogistics(scope.row)">修改物流</span>
								<span class="pointer" @click="deliver(scope.row.detailId,0,item.orderId)" v-if="scope.row.orderStat==3">单独发货</span>
							</template>
						</el-table-column>
					</el-table>
				</div>
			</el-card>
		</div>
		<div v-else style="text-align: center;margin-top: 40px;width: 85%;">
			<img src="../../assets/images/image_kong.png" alt="">
			<div style="color: #8A8A8A;margin-top: 10px;font-size: 16px;">
				<span style="margin-right: 25px;">暂无数据</span>
			</div>
		</div>
		<div class="paginate" style="margin-right: 15%;">
			<el-pagination @current-change="handleCurrentChange" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize"
			 layout="total, prev, pager, next, jumper" :total="pageInfo.count">
			</el-pagination>
		</div>

		<!-- 查看评价-->
		<el-dialog title="查看评价" v-model="dialogFormVisible">
			<el-form label-width="120px">
				<el-form-item label="评价时间：">
					<span>{{ f.evaluateTime }}</span>
				</el-form-item>
				<el-form-item label="评价星级：">
					<span>{{ f.evaluateStar }}星</span>
				</el-form-item>
				<el-form-item label="评价内容：">
					<span>{{ f.evaluateContent }}</span>
				</el-form-item>
				<el-form-item label="图片：">
					<img :src="item" alt="" v-for="item in f.evaluateImage" class="img-preview" @click="previewImage(item)" style="margin-right: 10px;">
					<span v-if="f.evaluateImage==''">无</span>
				</el-form-item>
			</el-form>
		</el-dialog>
		<div class="weui-gallery" style="display: block;z-index: 9999;" v-show="img.is_preview">
			<span class="weui-gallery__img" :style="{backgroundImage:img.preview_url,transform:img.transform}" @click="hidePreview"></span>
			<div class="weui-gallery__opr white_pointer">
				<div class="weui-gallery__del" @click.prevent="rotate()">
					<img src="../../assets/images/xuanzhuan.png" height="25" width="25">
					<span class="weui-span_del">旋转</span>
				</div>
			</div>
		</div>

		<!-- 物流信息 -->
		<el-dialog title="物流信息" v-model="dialogVisible2" size="small">
			<div class="modal-body">
				<div class="form-group">
					<span>快递公司：{{ logistics_info.orderLogicCompany }}</span>
				</div>
				<div class="form-group">
					<div class="input-group">
						<span>物流单号：{{ logistics_info.orderLogicNumber }}</span>
					</div>
				</div>
				<div class="box-footer box-comments" style="height: 350px; overflow: auto;">
					<div class="box-comment" v-for="(item,index) in logisticsList">
						<span class="img-circle img-sm is_new_express" v-if="index==0">最新</span>
						<div class="comment-text">
							<div class="username">
								<span v-if="index==0" style="color: rgb(201, 48, 44)">
									{{ item.time }}
								</span>
								<span v-else>{{ item.time }}</span>
							</div>
							<span v-if="index==0" style="color: rgb(201, 48, 44)">
								{{ item.context }}
							</span>
							<span v-else>{{ item.context }}</span>
						</div>
					</div>
				</div>
			</div>

		</el-dialog>

		<!-- 发送物流信息 -->
		<el-dialog title="填写物流信息" v-model="dialogVisible" size="tiny">
			<el-form :model="form" ref="f" style="width: 85%;">
				<el-form-item label="物流公司:" :label-width="formLabelWidth">
					<el-select v-model="form.orderLogicCompany">
						<el-option :label="item.logisticsName" :value="item.logisticsName" v-for="item in company_list"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="物流号:" :label-width="formLabelWidth">
					<el-input v-model.trim="form.orderLogicNumber"></el-input>
				</el-form-item>
			</el-form>
			<div style="text-align: center;margin-top: 30px;">
				<el-button type="primary" @click="sendOut()" :disabled="!form.orderLogicCompany || !form.orderLogicNumber" :loading="loading">确认
				</el-button>
			</div>
		</el-dialog>

		<!-- 退款原因-->
		<el-dialog title="退款原因" v-model="dialogFormVisible2">
			<el-form label-width="120px">
				<el-form-item label="原因：">
					<span>{{ remark }}</span>
				</el-form-item>
			</el-form>
		</el-dialog>
	</div>
</template>
<style>
	.el-table-filter__list {
		height: auto;
		max-height: 200px;
		overflow: scroll;
	}

	.box-comments {
		background: #f7f7f7;
	}

	.box-comments .comment-text {
		margin-left: 40px;
		color: #555;
	}

	.box-comments .username {
		color: #444;
		display: block;
		font-weight: 600;
	}

	.box-comments .box-comment {
		padding: 8px 0;
		border-bottom: 1px solid #eee;
	}

	.is_new_express {
		color: #fff;
		background: #c9302c;
		line-height: 30px;
		font-size: 1rem;
		padding-left: 3px;
		float: left;
		width: 30px !important;
		height: 30px !important;
	}

	.box-footer {
		border-bottom-left-radius: 3px;
		border-top: 1px solid #f4f4f4;
		padding: 10px;
	}

	.el-tabs__item {
		font-size: 18px;
	}

	.input2 {
		width: 180px;
	}

	.select {
		display: flex;
		padding: 10px;
		align-items: center;
		justify-content: center;
	}
</style>
<script>
	export default {
		data() {
			return {
				table_loading: false,
				loading: false,
				formLabelWidth: '100px',
				formInline: {
					type: 'orderId',
					orderId: '',
					serialNo: '',
					orderPayType: '',
					pageNum: '',
					pageSize: 5,
					desc: 'DESC',
					orderIsRemind: '',
					userName: '',
					storeName: '',
					goodName: '',
					startTime: '',
					endTime: '',
					name: ''
				},
				pageInfo: {
					pageNo: 1,
					pageSize: 5,
					count: 1,
					dtos: []
				},
				activeName: '0',
				dialogVisible: false,
				dialogVisible2: false,
				dialogVisible3: false,
				dialogFormVisible: false,
				dialogFormVisible2: false,
				form: {
					orderLogicCompany: '',
					orderLogicNumber: '',
					orderId: '',
					flag: '',
					detailId: ''
				},
				f: {
					evaluateImage: []
				},
				type: '',
				URL: URL,
				orderState: [{
					text: '待付款',
					value: '1'
				}, {
					text: '取消',
					value: '2'
				}, {
					text: '待发货',
					value: '3'
				}, {
					text: '待收货',
					value: '4'
				}, {
					text: '待评价',
					value: '5'
				}, {
					text: '已完成',
					value: '6'
				}],
				payWay: [{
					text: '抵用券',
					value: '1'
				}, {
					text: '现金支付',
					value: '2'
				}, {
					text: '混合支付',
					value: '3'
				}],
				logisticsList: [],
				logistics_info: {},
				company_list: [],
				orderLogicCompany: '',
				showSource: false,
				typeList: [{
					text: '光元',
					value: '1'
				}, {
					text: '现金',
					value: '4'
				}, {
					text: '支付宝',
					value: '5'
				}, {
					text: '微信',
					value: '6'
				}],
				numberObj: {
					totalNumber: 0,
					notPayNumber: 0,
					notReceiveNumber: 0,
					receiveNumber: 0,
					praiseNumber: 0,
					userCancelNumber: 0,
					sysCancelNumber: 0,
					okNumber: 0,
					returnNumber: 0
				},
				startTime: '',
				endTime: '',
				detail: {
					post_img: [],
					remark: ''
				},
				img: {
					is_preview: false,
					preview_url: '',
					image_index: null,
					preview_images: [],
					transform: ''
				},
				remark: '',
				findData: '',
				fileTemp: '',
				file: '',
				accountList: [],
				appData: '',
			}
		},
		created() {
			this.appData = JSON.parse(sessionStorage.getItem('permission')).appData
			this.fetchNumber();
			this.fetchData(this.pageInfo.pageNum);
			this.fetchCompany()
		},

		mounted() {

		},
		methods: {
			toLead(){
				if(this.orderLogicCompany == '') {
					this.showMsg('请选择物流公司')
					return
				}
			    document.getElementById('excel').click()
			},
			updata(event){
			    var data={
			        excel:event.target.files[0],
					orderLogicCompany: this.orderLogicCompany
			    }
			    this.dataApi.ajaxExcel('dealersImport',data, res => {
			        if (res.responseType == 'S') {
			             this.showMsg('导入成功')
						 this.fetchData(this.pageInfo.pageNum);
			             $('#excel').val('')
			        } else{
						$('#excel').val('')
					}
			    });
			},
			importf(obj) {
			 
			        let _this = this;
				
			    let inputDOM = this.$refs.inputer;   // 通过DOM取文件数据
				console.log(event)
			    this.file = event.currentTarget.files[0];  
				console.log(this.file, '上传数据')
				// 
				let data = {
					excel: this.file,
					
				}
				return
				this.dataApi.ajax('dealersImport', data, res => {
					console.log(res)
				});
				return
			    var rABS = false; //是否将文件读取为二进制字符串
			 
			    var f = this.file;
			 
			    var reader = new FileReader();
			 
			    //if (!FileReader.prototype.readAsBinaryString) {
			 
			    FileReader.prototype.readAsBinaryString = function(f) {
			 
			    var binary = "";
			 
			    var rABS = false; //是否将文件读取为二进制字符串
			 
			    var pt = this;
			 
			    var wb; //读取完成的数据
			 
			    var outdata;
			 
			    var reader = new FileReader();
			 
			    reader.onload = function(e) {
			 
			        var bytes = new Uint8Array(reader.result);
			 
			        var length = bytes.byteLength;
			 
			        for(var i = 0; i < length; i++) {
			 
			             binary += String.fromCharCode(bytes[i]);
			 
			        }
			 
			        var XLSX = require('xlsx');
			 
			        if(rABS) {
			 
			             wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
			 
			                  type: 'base64'
			 
			             });
			 
			        } else {
			 
			             wb = XLSX.read(binary, {
			 
			                  type: 'binary'
			 
			             });
			 
			        }
			 
			        // outdata就是你想要的东西 excel导入的数据
			 
			        outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]); 
					console.log(outdata, '导入数据')
			        // excel 数据再处理
			 
			        let arr = []
			 
			        outdata.map(v => {
			 
			             let obj = {}
			 
			             obj.account = v.ad
			 
			             obj.name = v.重坦
			 
			 
			             arr.push(obj)
			 
			        })
			 
			        _this.accountList = [...arr];
			 
			        console.log( _this.accountList, 789)
			 
			         _this.reload();
			 
			         }
			 
			         reader.readAsArrayBuffer(f);
			 
			     }
			 
			     if(rABS) {
			 
			          reader.readAsArrayBuffer(f);
			 
			     } else {
			 
			          reader.readAsBinaryString(f);
			 
			     }
			 
			 
			 
			},
			handleChange(file, fileList) {

				this.fileTemp = file.raw

			},

			handleRemove(file, fileList) {

				this.fileTemp = null

			},
			fetchData(page = 1) {
				if (this.startTime && this.endTime) {
					this.formInline.startTime = dateFormat(this.startTime)
					this.formInline.endTime = dateFormat(this.endTime)
					if (this.formInline.startTime > this.formInline.endTime) {
						this.$message({
							type: 'warning',
							message: '开始时间不能大于结束时间'
						});
						return;
					}
				} else {
					this.formInline.startTime = ''
					this.formInline.endTime = ''
				}
				if (this.startTime && !this.endTime) {
					this.$message({
						type: 'warning',
						message: '请选择结束时间'
					});
					return;
				}
				if (!this.startTime && this.endTime) {
					this.$message({
						type: 'warning',
						message: '请选择开始时间'
					});
					return;
				}
				this.table_loading = true;
				this.pageInfo.pageNum = page
				this.formInline.pageNum = page
				this.formInline.orderStat = this.activeName
				this.formInline[this.formInline.type] = this.formInline.name
				console.log(this.formInline, '全部订单列表')
				this.dataApi.ajax('selectPageWebShopOrder', this.formInline, res => {
					this.table_loading = false;
					if (res.responseType === 'S') {
						this.pageInfo = res
					}
				});
			},
			fetchCompany() {
				this.dataApi.ajax('selectShopLogistics', null, res => {
					if (res.responseType === 'S') {
						this.company_list = res.dtos
					}
				});

			},
			fetchNumber() {
				let data = {}
				this.dataApi.ajax('countWebShopOrder', data, res => {
					if (res.responseType === 'S') {
						this.numberObj = res
					}
				});

			},
			findDataInfo() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 订单查询
				 * @param 
				 * @return 
				 * @createTime: 2020/7/13
				 */
				this.fetchData(1)
				// this.findData = 'f'
				// if (this.startTime && this.endTime) {
				// 	this.formInline.startTime = dateFormat(this.startTime)
				// 	this.formInline.endTime = dateFormat(this.endTime)
				// 	if (this.formInline.startTime > this.formInline.endTime) {
				// 		this.$message({
				// 			type: 'warning',
				// 			message: '开始时间不能大于结束时间'
				// 		});
				// 		return;
				// 	}
				// } else {
				// 	this.formInline.startTime = ''
				// 	this.formInline.endTime = ''
				// }
				// if (this.startTime && !this.endTime) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '请选择结束时间'
				// 	});
				// 	return;
				// }
				// if (!this.startTime && this.endTime) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '请选择开始时间'
				// 	});
				// 	return;
				// }
				// this.table_loading = true;
				// this.pageInfo.pageNum = 1
				// this.formInline.pageNum = 1
				// this.formInline.orderStat = '0'
				// this.formInline[this.formInline.type] = this.formInline.name
				// // console.log(this.formInline, '全部订单列表')
				// this.dataApi.ajax('selectPageWebShopOrder', this.formInline, res => {
				// 	this.table_loading = false;
				// 	if (res.responseType === 'S') {
				// 		this.pageInfo = res
				// 		this.formInline = {
				// 			type: 'orderId',
				// 			orderId: '',
				// 			serialNo: '',
				// 			orderPayType: '',
				// 			pageNum: '',
				// 			pageSize: 5,
				// 			desc: 'DESC',
				// 			orderIsRemind: '',
				// 			userName: '',
				// 			storeName: '',
				// 			goodName: '',
				// 			startTime: '',
				// 			endTime: '',
				// 			name: ''
				// 		}
				// 	}
				// });

			},
			handleCurrentChange(val) {
				this.fetchData(val);
			},
			handleClick(tab) {
				this.fetchNumber()
				this.fetchData(1)
			},
			order(column) {
				if (!column.order) {
					return;
				}
				if (column.order == 'ascending') {
					this.formInline.desc = 'ASC'
				} else {
					this.formInline.desc = 'DESC'
				}
				this.fetchData(this.pageInfo.pageNum)

			},
			//清空
			clear() {
				this.formInline = {
					type: 'orderId',
					orderId: '',
					serialNo: '',
					orderPayType: '',
					pageNum: '',
					pageSize: 5,
					desc: 'DESC',
					orderIsRemind: '',
					userName: '',
					storeName: '',
					goodName: '',
					startTime: '',
					endTime: '',
					name: ''
				}
				this.startTime = ''
				this.endTime = ''
			},
			changeType() {
				this.formInline.orderId = ''
				this.formInline.serialNo = ''
			},
			checkReturn(item) {
				this.$confirm('确定收到退货?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					var arr = []
					for (var i = item.length - 1; i >= 0; i--) {
						arr[i] = item[i].refundsId
					}
					this.dataApi.ajax('MallOrderControl/editRefund', {
						refundsState: 9,
						refundsId: JSON.stringify(arr)
					}, res => {
						this.table_loading = false;
						if (res.responseType === 0) {
							this.$message({
								type: 'success',
								message: '确认收到退货成功!'
							});
							this.fetchRefunds(this.pageInfo.pageNo);
						}
					});
				}).catch(() => {

				});
			},
			sendOut() {
				this.loading = true
				if (this.form.flag == 'undefined') {
					this.dataApi.ajax('editShopOrderDetail', this.form, res => {
						this.loading = false
						if (res.responseType === 'S') {
							this.dialogVisible = false
							this.showMsg('修改成功')
							this.fetchData(this.pageInfo.pageNum)

						}
					});
				} else {
					this.dataApi.ajax('deliverOrder', this.form, res => {
						this.loading = false
						if (res.responseType === 'S') {
							this.dialogVisible = false
							this.showMsg('发货成功')
							this.fetchData(this.pageInfo.pageNum)
						}
					});
				}
			},
			findState(state) {
				for (var i = this.orderState.length - 1; i >= 0; i--) {
					if (this.orderState[i].value == state) {
						return this.orderState[i].text
					}

				}
			},
			deliver(id, type, orderId) {
				this.dialogVisible = true
				if (type == 0) {
					this.form = {
						orderLogicCompany: '',
						orderLogicNumber: '',
						detailId: id,
						orderId: orderId,
						flag: type
					}
				} else {
					this.form = {
						orderLogicCompany: '',
						orderLogicNumber: '',
						orderId: id,
						flag: type
					}
				}
			},
			editGold(id) {
				this.dataApi.ajax('singleShopEvaluatByExample', {
					orderId: id,
					stat: 1,
					evaluateType: 1
				}, res => {
					if (res.responseType === 'S') {
						this.dialogFormVisible = true
						this.f = res
					}
				});
			},
			//导出
			deriveList() {
				let vm = this
				console.log(vm.formInline)
				let startTime = ''
				let endTime = ''
				let orderStatus = ''
				let storeId = vm.formInline.storeId
				if (vm.startTime > vm.endTime) {
					this.showMsg('开始时间不能大于结束时间', 'warning');
					return;
				}
				if(vm.startTime && vm.endTime) {
					startTime = dateFormat(vm.startTime)
					endTime =  dateFormat(vm.endTime)
				} else {
					startTime = ''
					endTime = ''
				}
				// http://192.168.11.112:8080/enve-web
				let host = 'https://console.hzsuhu.cn/enve'
				location.href = encodeURI(encodeURI(host + "/WithdrawControl/exportOrder?startTime=" + startTime +
					'&endTime=' + endTime + '&storeId=' + storeId))
			},
			submitForm() {
				this.f.ebbyYuan = this.ebbyYuan
				this.f.cash = this.cash
				this.dataApi.ajax('MallOrderListControl/EditOrderPrice', this.f, res => {
					if (res.responseType === 0) {
						this.$message({
							type: 'success',
							message: '修改成功!'
						});
						this.dialogFormVisible = false
						this.fetchData(this.pageInfo.pageNo)
					}
				});
			},
			handleCheckedCitiesChange(value) {
				let arr = []
				for (var i = this.arr.length - 1; i >= 0; i--) {
					for (var j = this.checked.length - 1; j >= 0; j--) {
						if (arr.indexOf(this.checked[j] === -1) && this.arr[i] === this.checked[j]) {
							arr.push(this.checked[j])
						}
					}
				}
				let checkedCount = arr.length;
				this.checkAll = checkedCount === this.arr.length;
				this.isIndeterminate = checkedCount > 0 && checkedCount < this.arr.length;
			},
			handleCheckAllChange(event) {

				if (event.target.checked == false) {
					for (var i = this.arr.length - 1; i >= 0; i--) {
						for (var j = this.checked.length - 1; j >= 0; j--) {
							if (this.arr.indexOf(this.checked[j]) !== -1) {
								this.checked.splice(j, 1)
							}
						}
					}

				} else {
					this.isIndeterminate = false;
					for (var i = this.gridData.length - 1; i >= 0; i--) {
						if (this.checked.indexOf(this.arr[i]) === -1) {
							this.checked.push(this.arr[i])
						}
					}
				}

			},
			reminder(id) {
				this.$confirm('请及时前去发货', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.dataApi.ajax('MallOrderControl/remindOrder', {
						orderId: id
					}, res => {
						if (res.responseType === 0) {
							this.$message({
								type: 'success',
								message: '处理成功!'
							});
							this.fetchData(this.pageInfo.pageNo)
						}
					});
				}).catch(() => {

				});

			},
			logistics(item) {
				this.logisticsList = []
				this.logistics_info.orderLogicCompany = item.orderLogicCompany
				this.logistics_info.orderLogicNumber = item.orderLogicNumber
				this.dialogVisible2 = true
				this.dataApi.ajax('logisticsQuery', {
					logisticsName: item.orderLogicCompany,
					logisticsNo: item.orderLogicNumber
				}, res => {
					if (res.responseType === 'S') {
						this.logisticsList = res.data
					}
				});
			},
			changeLogistics(item) {
				this.dialogVisible = true
				this.form = {
					orderLogicCompany: item.orderLogicCompany,
					orderLogicNumber: item.orderLogicNumber,
					detailId: item.detailId
				}
			},
			findType(type) {
				for (var i = this.payWay.length - 1; i >= 0; i--) {
					if (type == this.payWay[i].value) {

						return this.payWay[i].text
					}
				}
			},
			previewImage(src) {
				this.img.is_preview = true;
				this.img.preview_url = `url(${src})`;
				this.img.preview_images = this.images;
				this.img.transform = '';
			},
			hidePreview() {
				this.img.is_preview = false;
				this.img.preview_url = null;
				this.img.image_index = null;
				this.img.preview_images = [];
				this.img.transform = '';
			},
			rotate() {
				if (this.img.transform == '') {
					this.img.transform = 'rotate(90deg)'
				} else if (this.img.transform == 'rotate(90deg)') {
					this.img.transform = 'rotate(180deg)'
				} else if (this.img.transform == 'rotate(180deg)') {
					this.img.transform = 'rotate(270deg)'
				} else if (this.img.transform == 'rotate(270deg)') {
					this.img.transform = ''
				}
			}

		}
	}
</script>
<style>
	.introduceHeader {
		display: flex;
		justify-content: space-between;
		background-color: #f4f5f6;
		width: 90%;
		margin-bottom: 20px;
		padding-right: 20px;
		border: 1px solid #dfe6ec;
	}

	.introduceHeader .introduceProduce {
		background-color: #FFFFFF;
		padding: 15px;
		border-top: 3px solid #4F94CD;

		border-right: 1px solid #dfe6ec;

	}

	.introduceHeader .introduceAdd {
		background-color: #4F94CD;
		color: #FFFFFF;
		margin-right: 20px;
		height: 40px;
		line-height: 20px;
		padding: 10px;
		align-self: center;
		border-radius: 5px;
	}
</style>
